﻿using System;
using System.Configuration;
namespace WinCoreV3Run
{
    public class MyParam
    {
        public static int cutX;
        public static int cutY;
        public static int cutWidth;
        public static int cutHeight;

        public static string allPath;
        public static string nullPath;
        public static string errPath;

        public static string svmXml;
        public static int showWindow;
        public static int errTimes;
        public static float probility;
        public static string codeNumber;
        public static int swapRGB;
        public static int saveNull;
        public static int showTime;
        public static void MyParam_Init(string codeNum)
        {
            codeNumber = codeNum;

 
            //allPath = @"D:\AI\all\";
            //nullPath = @"D:\AI\null\";
            //errPath = @"D:\AI\err\";//读取配置文件中imageSavePath
            //svmXml = @"D:\ModelV3_NingBo.pb";

            //cutX = 175;
            //cutY = 45;
            //cutWidth = 280;
            //cutHeight = 280;

            //showWindow = 0;
            //errTimes = 5;
            //probility =0.85f;
            //swapRGB = 1;
            //saveNull = 0;
            //showTime = 1;




            Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
            allPath = config.AppSettings.Settings["allPath"].Value;
            nullPath = config.AppSettings.Settings["nullPath"].Value;
            errPath = config.AppSettings.Settings["errPath"].Value;//读取配置文件中imageSavePath
            svmXml = config.AppSettings.Settings["svmXml"].Value;

            cutX = Convert.ToInt32(config.AppSettings.Settings["cutX"].Value);
            cutY = Convert.ToInt32(config.AppSettings.Settings["cutY"].Value);
            cutWidth = Convert.ToInt32(config.AppSettings.Settings["cutWidth"].Value);
            cutHeight = Convert.ToInt32(config.AppSettings.Settings["cutHeight"].Value);

            showWindow = Convert.ToInt32(config.AppSettings.Settings["showWindow"].Value);
            errTimes = Convert.ToInt32(config.AppSettings.Settings["errTimes"].Value);
            probility = Convert.ToSingle(config.AppSettings.Settings["probility"].Value);
            swapRGB = Convert.ToInt32(config.AppSettings.Settings["swapRGB"].Value);
            saveNull = Convert.ToInt32(config.AppSettings.Settings["saveNull"].Value);
            showTime = Convert.ToInt32(config.AppSettings.Settings["showTime"].Value);
        }
        public static string toString()
        {
            string res1 = string.Format("cutX={0}\ncutY={1}\ncutWidth={2}\ncutHeight={3}",
                cutX, cutY, cutWidth, cutHeight);
            string res2 = string.Format("allPath={0}\nnullPath={1}\nerrPath={2}\ncodeNumber={3}",
             allPath, nullPath, errPath, codeNumber);
            string res3 = string.Format("svmXml={0}\nshowWindow={1}\nerrTimes={2}\nprobility={3}\nswapRGB={4}\nsaveNull={5}\nshowTime={6}",
               svmXml, showWindow, errTimes, probility, swapRGB, saveNull, showTime);
            res1 = res1 + "\n" + res2 + "\n" + res3;
            return res1;
        }

    }
}
